package com.dm.voicesubtitle;

import com.dm.voicesubtitle.gui.SubtitleWindow;
import com.dm.voicesubtitle.config.AppConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;

/**
 * 语音弹幕系统主程序
 */
public class Main {
    private static final Logger logger = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) {
        try {
            // 设置系统外观
//            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeel());
            
            logger.info("启动语音弹幕系统...");
            
            // 加载配置
            AppConfig config = AppConfig.getInstance();
            logger.info("配置加载完成: {}", config);
            
            // 启动GUI界面
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        SubtitleWindow window = new SubtitleWindow();
                        window.setVisible(true);
                        logger.info("GUI界面启动完成");
                    } catch (Exception e) {
                        logger.error("GUI界面启动失败", e);
                        JOptionPane.showMessageDialog(null, 
                            "GUI界面启动失败: " + e.getMessage(), 
                            "错误", 
                            JOptionPane.ERROR_MESSAGE);
                    }
                }
            });
            
        } catch (Exception e) {
            logger.error("系统启动失败", e);
            JOptionPane.showMessageDialog(null, 
                "系统启动失败: " + e.getMessage(), 
                "错误", 
                JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
    }
} 